<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
	<title>聊天室登陆</title>
</head>
<body>
	昵称<input type="text" name="nickname">
	<br>
	<button onclick="sub()">进入</button>
</body>
</html> 
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
	function sub(){
		// alert($)
		let nickname = $("input[name = 'nickname']").val();
		$.ajax({
			url:'http://******/login.php',
			data:{nickname:nickname},
			type:'post',
			dataType:'json',
			success:function(ret){
				// console.log(ret);
				if(ret.code == 1){
					alert('角色已创建');
					localStorage.setItem("uid",ret.data.uid);
					localStorage.setItem("nickname",ret.data.nickname);
					location = './content.html';
				}else{
					alert('角色创建失败');
				}
			},
			error:function(err){
				console.log(err);
			}
		})
	}
</script>